unit dgEditBank ;

interface

uses Windows,
   SysUtils,
   Classes,
   Graphics,
   Forms,
   Controls,
   StdCtrls,
   Buttons,
   ExtCtrls,
   SpTBXEditors,
   SpTBXControls,
   TBXDkPanels,
   uObjects,
   GDIPAPI,
   GDIPOBJ ;

type
   TdlgEditBank = class( TForm )
      Panel : TSpTBXPanel ;
      btOK : TSpTBXButton ;
      btCancel : TSpTBXButton ;
      SpTBXGroupBox2 : TSpTBXGroupBox ;
      edDesignator : TSpTBXButtonEdit ;
      SpTBXGroupBox3 : TSpTBXGroupBox ;
      edLabel : TSpTBXButtonEdit ;
      SpTBXGroupBox1 : TSpTBXGroupBox ;
      seSizeX : TSpTBXSpinEdit ;
      seSizeY : TSpTBXSpinEdit ;
      btApply : TSpTBXButton ;
      procedure btOKClick( Sender : TObject ) ;
      procedure FormCreate( Sender : TObject ) ;
      procedure btApplyClick( Sender : TObject ) ;
   private
      fBank : TMedaBank ;
      procedure SetBank( const Value : TMedaBank ) ;
      procedure SetTitle( const Value : string ) ;
   public
      property Title : string write SetTitle ;
      property Bank : TMedaBank read FBank write SetBank ;
   end ;

implementation

{$R *.dfm}

{ TdlgEditBank }

procedure TdlgEditBank.btApplyClick( Sender : TObject ) ;
var
   iRect            : TGPRectF ;
begin
   if assigned( fBank ) then begin
      fBank.Name := edLabel.Text ;
      fBank.Designator := edDesignator.Text ;
      iRect.Width := seSizeX.Value ;
      iRect.Height := seSizeY.Value ;
      iRect.X := -iRect.Width / 2 ;
      iRect.Y := -iRect.Height / 2 ;
      fBank.Outline := iRect ;
      fBank.BuildOutline ;
   end ;
end ;

procedure TdlgEditBank.FormCreate( Sender : TObject ) ;
begin
   Caption := ' Add Bank' ;
   fBank := nil ;
   edLabel.Text := '' ;
   edDesignator.Text := '' ;
end ;

procedure TdlgEditBank.SetBank( const Value : TMedaBank ) ;
begin
   fBank := Value ;
   if assigned( fBank ) then begin
      edLabel.Text := fBank.Name ;
      edDesignator.Text := fBank.Designator ;
      seSizeX.Value := fBank.Outline.Width ;
      seSizeY.Value := fBank.Outline.Height ;
   end ;
end ;

procedure TdlgEditBank.SetTitle( const Value : string ) ;
begin
   Caption := Value ;
end ;

procedure TdlgEditBank.btOKClick( Sender : TObject ) ;
begin
   btApplyClick( Sender ) ;
end ;

end.

